﻿using MPR.Poker.Model.SYS;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MPR.Poker.Model.LIS;
using System.Data.Entity.SqlServer;
using System.Data.Entity.Infrastructure;

namespace MPR.Poker.DALEntity
{
    [DbConfigurationType(typeof(DbContextConfiguration))]
    public class PokerLife : DbContext
    {
        public PokerLife()
            : base(DAL_Globals.ConnectString)
        {
            Database.SetInitializer<PokerLife>(null);//Không cần tạo Database
            this.Configuration.LazyLoadingEnabled = false;
        }

        #region LIS
        public DbSet<LIS_Country> LIS_Countrys { get; set; }
        public DbSet<LIS_Province> LIS_Provinces { get; set; }
        public DbSet<LIS_Currency> LIS_Currencys { get; set; }
        public DbSet<LIS_Prize> LIS_Prizes { get; set; }
        public DbSet<SYS_DisplayConfig> SYS_DisplayConfigs { get; set; }
        #endregion

        #region SYS
        public DbSet<SYS_Error> SYS_Errors { get; set; }
        public DbSet<SYS_User> SYS_Users { get; set; }
        public DbSet<SYS_Event> SYS_Events { get; set; }
        public DbSet<SYS_MemberType> SYS_MemberTypes { get; set; }
        public DbSet<SYS_Member> SYS_Members { get; set; }
        public DbSet<SYS_Tournament> SYS_Tournaments { get; set; }
        public DbSet<SYS_TournamentStep> SYS_TournamentSteps { get; set; }
        public DbSet<SYS_TournamentStepTable> SYS_TournamentStepTables { get; set; }
        public DbSet<SYS_TournamentStepTableMember> SYS_TournamentStepTableMembers { get; set; }
        #endregion
    }

    class DbContextConfiguration : DbConfiguration
    {
        public DbContextConfiguration()
        {
            this.SetProviderServices(SqlProviderServices.ProviderInvariantName, SqlProviderServices.Instance);
        }
    }

    //public class MyConfiguration : DbConfiguration
    //{
    //    public MyConfiguration()
    //    {
    //        SetExecutionStrategy("System.Data.SqlClient", () => new SqlAzureExecutionStrategy());
    //        SetDefaultConnectionFactory(new LocalDbConnectionFactory("v11.0"));
    //    }
    //}
}
